/*****************************************************************

Agent offering the painting service: AgPainter.java



 *****************************************************************/



package fishBids.group3;



import jade.content.lang.Codec;
import jade.content.lang.sl.SLCodec;
import jade.content.onto.Ontology;
import jade.core.AID;
import jade.core.Agent;
import jade.core.behaviours.ParallelBehaviour;
import jade.util.leap.HashMap;
import jade.util.leap.Map;
import es.upm.agents.ontology.Fish_BidsOntology;
import fishBids.group3.behaviour.bank.BankAuctionOverBehaviour;
import fishBids.group3.behaviour.bank.BankBuyProductBehaviour;
import fishBids.group3.behaviour.bank.BankCreateAccountBehaviour;
import fishBids.group3.behaviour.bank.BankGetAmountBehaviour;
import fishBids.group3.behaviour.bank.BankGetMoneyBehaviour;
import fishBids.group3.behaviour.bank.BankSellProductBehaviour;
import fishBids.group3.behaviour.common.FindTypeBehaviour;
import fishBids.group3.common.Constants;
import fishBids.group3.utils.Utils;







/**

 * This agent has the following functionality: 

 * <ul>

 * <li> It registers itself in the DF as PAINTER

 * <li> Waits for requests of its painting service

 * <li> If any estimation request arrives, it answers with a random value

 * <li> Finally, it waits for the client answer

 * </ul>

 * @author Gabriel & Mai, UPM

 * @version $Date: 2009/04/01 13:45:18 $ $Revision: 1.1 $

 **/





public class AgBank extends Agent {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2568456083895417860L;
	private Codec codec = new SLCodec(); 
	private Ontology ontology = Fish_BidsOntology.getInstance(); 
	Map agentsAccounts = new HashMap();
	Map agentsItemsObtained = new HashMap();
	private final AID marketID = new AID();


	protected void setup()

	{

		//System.out.println("Bank3: enters into the system");
		this.getContentManager().registerLanguage(codec); 
		this.getContentManager().registerOntology(ontology);

		Utils.registerInDF(this.getName(), Constants.BANK, this);
		doWait(10000);



//		BEHAVIOURS ****************************************************************
		addBehaviour(new FindTypeBehaviour( Constants.MARKET,this,marketID,5000));
		ParallelBehaviour parallelBehaviour = new ParallelBehaviour();
		parallelBehaviour.addSubBehaviour(new BankCreateAccountBehaviour(codec,ontology,this));
		parallelBehaviour.addSubBehaviour(new BankBuyProductBehaviour(codec,ontology,this));
		parallelBehaviour.addSubBehaviour(new BankSellProductBehaviour(codec,ontology,this) );
		parallelBehaviour.addSubBehaviour(new BankGetMoneyBehaviour(this,codec,ontology) );
		parallelBehaviour.addSubBehaviour(new BankGetAmountBehaviour(this,codec,ontology) );
		parallelBehaviour.addSubBehaviour(new BankAuctionOverBehaviour(this,agentsAccounts) );
		addBehaviour(parallelBehaviour);

    }


	public Map getAgentsAccounts() {
		return agentsAccounts;
	}


	public void setAgentsAccounts(Map agentsAccounts) {
		this.agentsAccounts = agentsAccounts;
	}


	public Map getAgentsItemsObtained() {
		// TODO Auto-generated method stub
		return agentsItemsObtained;
	}


	public AID getMarketID() {
		return marketID;
	}


	public Codec getCodec() {
		return codec;
	}


	public void setCodec(Codec codec) {
		this.codec = codec;
	}


	public Ontology getOntology() {
		return ontology;
	}


	public void setOntology(Ontology ontology) {
		this.ontology = ontology;
	}



}

